#include <stdio.h>
#include <uv.h>

int64_t counter = 0;

void wait_for_a_while(uv_idle_t *handle) {
    counter++;
    if (counter % 10000 == 0) {
        printf(".");
        fflush(stdout);
    }

    if (counter >= 10e6) {
        uv_idle_stop(handle);
        printf("\n");
    }
}

int main() {
    uv_loop_t *loop = uv_default_loop();
    uv_idle_t idler;

    uv_idle_init(loop, &idler);
    uv_idle_start(&idler, wait_for_a_while);

    printf("Starting the loop\n");
    uv_run(loop, UV_RUN_DEFAULT);
    printf("Loop finished\n");

    uv_loop_close(loop);
    return 0;
}